package com.yy.jhl.ui.manager.presenter;

import com.google.gson.Gson;
import com.yy.common.commonutils.StringUtil;
import com.yy.jhl.api.Api;
import com.yy.jhl.api.RxSubscriber;
import com.yy.jhl.app.AppConstant;
import com.yy.jhl.bean.CGSOrderInfoList;
import com.yy.jhl.bean.JGOrderInfo;
import com.yy.jhl.bean.JGOrderListInfo;
import com.yy.jhl.ui.manager.contract.JGOrderListContract;
import com.yy.jhl.ui.manager.contract.MenuTwoJGContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.ResponseBody;

/**
 * Created by libingn on 2017/12/14.
 */

public class JGOrderListPresenter extends JGOrderListContract.Presenter {
    @Override
    public void getOrderList(int type,int status, int page_size,String project_id, boolean isDialog) {
        Map<String,Object> requestMap = new HashMap<>();
        requestMap.put("type",type);
        if (status != 0){
            requestMap.put("status",status);
        }
        if (!StringUtil.isEmpty(project_id)){
            requestMap.put("project_id",project_id);
        }
        requestMap.put("page",page_size);
        requestMap.put("page_size", AppConstant.PAGE_SIZE);
        mRxManage.addSubscription(Api.getDefault().cgsGetJGOrderList(requestMap), new RxSubscriber<ResponseBody>(mContext,isDialog) {
            @Override
            protected void _onNext(String result) {
                JGOrderListInfo info = new Gson().fromJson(result,JGOrderListInfo.class);
                mView.getOrderListSuccess(info.getData());
            }

            @Override
            protected void _onError(String message) {
                mView.getOrderListFail();
            }
        });
    }
}
